﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations;
using System.Data.Entity.ModelConfiguration;

namespace DataModel
{
    public class BookCopy
    {
        [Column("ID")]
        public int ID { get; set; }
        [Column("BARCODE")]
        public int Barcode { get; set; }            // ID numberr from Barcode
        [Column("STATE")]
        public int State { get; set; }              // state (new,dirty,damaged ...)
        [Column("PURCHASEDATE")]
        public DateTime PurchaseDate { get; set; }  // date buyed
        [Column("STATUS")]
        public string Status { get; set; }          // current status - free, reserved, borrowed

        [Column("BORROWDATE")]
        public DateTime BorrowDate { get; set; }    // when borrowed? 
        [Column("RETURNDATE")]
        public DateTime ReturnDate { get; set; }    // when returned?

        public virtual Person Borrower { get; set; }

    }

    public class BookCopyConfiguration : EntityTypeConfiguration<BookCopy>
    {
        public BookCopyConfiguration()
        {
            HasKey(x => x.ID);
            Property(x => x.ID).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
            HasOptional(x => x.Borrower);
            ToTable("BOOKCOPY");
        }
    }
}
